#include<bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10,M = 66,NM = 266;
inline int read()
{
    int f = 1,x = 0;
    char ch = getchar();
    while(ch > '9' || ch < '0')
    {
        if(ch == '-') f = -1;
        ch = getchar();
    }
    while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0',ch = getchar();
    return f * x;
}

inline void write(int x)
{
    if(x < 0) putchar('-'),x = -x;
    if(x > 9) write(x / 10);
    putchar(x % 10 + '0');
    return;
}
inline string reads()
{
    string s;
    char ch = getchar();
    while(ch != '\n' && ch != ' ') s += ch,ch = getchar();
    return s;
}
int n,m;
int a[N],b[N];
int T;
string s[M];
int t[NM][NM];
int x1[NM],x2[NM],x3[NM],x4[NM];
int main()
{
    freopen("arena.in","r",stdin);
    freopen("arena.out","w",stdout);
    n = read();
    m = read();
    for(int i = 1;i <= n;i++)
        a[i] = read();
    for(int i = 1;i <= n;i++)
        b[i] = read();
    int k = 1;
    while(pow(2,k) < n) k++;
    for(int i = 1;i <= k;i++)
        s[i] = reads();
    T = read();
    for(int i = 1;i <= T;i++)
    {
        x1[i] = read();
        x2[i] = read();
        x3[i] = read();
        x4[i] = read();
    }
    for(int i = 1;i <= T;i++)
        cout << 1 << endl;
    return 0;
}
